<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件流</title>
    <style>
        div{
            width: 300px;
            height: 300px;
            background-color: cyan;
        }
        p{
            width: 100px;
            height: 100px;
            background-color: red;
        }
        span{
            display: inline-block;
            width: 30px;
            height: 30px;

        }
    </style>
</head>
<body>

    <div>
        <p>
            <span>点我</span>
        </p>
    </div>
    
</body>
<script>
    let span = document.querySelector('span');
    span.addEventListener('click',(e)=>{
        console.log("span被点击了");
        e.stopPropagation();//阻止事件冒泡
        
    });
    let p = document.querySelector('p');
    p.addEventListener('click',(e)=>{
        console.log("span被点击了");
        
    });
    let div = document.querySelector('div');
    div.addEventListener('click',(e)=>{
        console.log("div被点击了");
        
    });
</script>
</html>